package com.rfid.project.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rfid.project.model.People;
import com.rfid.project.model.Position;
import com.rfid.project.model.ProjectDelivery;
import com.rfid.project.model.ProjectStakeholderType;

@Service
@Transactional
public class ProcessSourceForProjectDelivery{

	@Autowired
	private ProjectDeliveryService projectDeliveryService;

	@Autowired
	private PeopleService peopleService;

	public List<Process> getCurrentTaskListByProcessor(People people) {
		List<Process> resultList = new ArrayList<Process>();
		List<ProjectDelivery> projectDeliveries = null;
		if (people.getPosition().getId().equals(Position.PLAN_ID)) {
			// 如果当前用户为计划调度岗，则查询未审核的交付记录
			projectDeliveries = projectDeliveryService.findByStatus(people, ProjectStakeholderType.DEPT_PLAN, ProcessStatus.FINISH_APPLY);
		}
		if (projectDeliveries != null) {
			for (ProjectDelivery projectDelivery : projectDeliveries) {
				Process processTask = new Process();
				processTask.setBizId(projectDelivery.getId());
				processTask.setSubmitPerson(projectDelivery.getInputPerson());
				processTask.setSubmitTime(projectDelivery.getInputTime());
				processTask.setProcessStatusId(projectDelivery.getStatus());
				processTask.setProcessTypeId(ProcessType.PROJECT_DELIVERY_CHECK);
				processTask.setProcessTitle(projectDelivery.getProject()
						.getName() +"_"+ projectDelivery.getName()+ "_交付审核!");
				resultList.add(processTask);
			}
		}
		return resultList;
	}

	public List<Process> getCurrentTaskListByCreator(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Process> getHistoryTaskListByProcessor(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Process> getHistoryTaskListByCreator(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

}
